package com.dong.auth.module.oauth2.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.sql.Blob;
import java.util.Date;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 认证授权Token记录表
 * </p>
 *
 * @author zhao dong chao
 * @since 2021-09-03 53:12:32
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("oauth_access_token")
public class OauthAccessToken implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * Token标识：通过MD5加密access_token的值
     */
    @TableField("token_id")
    private String tokenId;

    /**
     * OAuth2AccessToken.java对象序列化内容
     */
    private Blob token;

    /**
     * 根据当前的username、client_id与scope通过MD5加密生成该字段的值
     */
    @TableId(value = "authentication_id", type = IdType.INPUT)
    private String authenticationId;

    /**
     * 用户名，若客户端没有用户名则该值等于client_id
     */
    @TableField("user_name")
    private String userName;

    /**
     * 认证授权客户端ID
     */
    @TableField("client_id")
    private String clientId;

    /**
     * OAuth2Authentication.java对象序列化内容
     */
    private Blob authentication;

    @TableField("refresh_token")
    private String refreshToken;

    @TableField("create_time")
    private Date createTime;

}
